<template>
  <div class="academic-container">
    <el-tabs v-model="activeName" class="class-tabs">
      <el-tab-pane label="J1 教学任务书" name="1">
        <el-table :data="tableData1" size="small">
          <el-table-column prop="classIndex" label="课次" width="100" />
          <el-table-column label="课时" align="center">
            <el-table-column prop="theoreticalClassHours" label="理论" width="120" />
            <el-table-column label="实训" width="120" prop="practicalTrainingHours" />
            <el-table-column prop="modular" label="模块" width="200" />
          </el-table-column>
          <el-table-column prop="contentCourses" label="教学内容" />
          <el-table-column prop="lecturerName" label="任课老师" width="100" align="center" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="J2 教师业务档案" name="2">
        <div class="bold flex alignCenter">
          <span style="margin-right: 15px;">教师基本情况表</span>
        </div>
        <div v-for="(item, index) in teacherFile" :key="index" style="margin-top: 10px;">
          <el-link :href="item.path" type="primary">{{item.name}}</el-link>
        </div>

        <div class="bold flex alignCenter" style="margin-top: 20px;">
          <span style="margin-right: 15px;">教师毕业证</span>
        </div>
        <div v-for="(item, index) in diplomaFile" :key="index" style="margin-top: 10px;">
          <el-link :href="item.path" type="primary">{{item.name}}</el-link>
        </div>

        <div class="bold flex alignCenter" style="margin-top: 20px;">
          <span style="margin-right: 15px;">学信网认证报告</span>
        </div>
        <div v-for="(item, index) in eduAuthFile" :key="index" style="margin-top: 10px;">
          <el-link :href="item.path" type="primary">{{item.name}}</el-link>
        </div>

        <div class="bold flex alignCenter" style="margin-top: 20px;">
          <span style="margin-right: 15px;">教师从业资格证</span>
        </div>
        <div v-for="(item, index) in teacherAuthFile" :key="index" style="margin-top: 10px;">
          <el-link :href="item.path" type="primary">{{item.name}}</el-link>
        </div>

        <div class="bold flex alignCenter" style="margin-top: 20px;">
          <span style="margin-right: 15px;">职业技能证书</span>
        </div>
        <div v-for="(item, index) in skillCertificateFile" :key="index" style="margin-top: 10px;">
          <el-link :href="item.path" type="primary">{{item.name}}</el-link>
        </div>
      </el-tab-pane>
      <el-tab-pane label="J2 听课评议表" name="3">
        <lessonEvaluationForm :info="info"></lessonEvaluationForm>
      </el-tab-pane>
      <el-tab-pane label="J3 考核评价记录" name="4">
        <assessmentEvaluationRecords :info="info" :activeName="activeName"></assessmentEvaluationRecords>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script setup lang="ts">
//听课评议表
import lessonEvaluationForm from "@/views/courseManage/components/lessonEvaluationForm.vue";
//考核评价记录
import assessmentEvaluationRecords from "@/views/courseManage/components/assessmentEvaluationRecords.vue";
const { proxy } = getCurrentInstance();
import useCounterStore from "@/store/counter";
const counter = useCounterStore();
let props = defineProps(["archiveBinding", "info"]);

let activeName = ref("1");
let tableData1 = ref([]); //教学任务书
let teacherFile = ref([]); //教师业务档案
let diplomaFile = ref([]); //教师毕业证
let eduAuthFile = ref([]); //学信网认证报告
let teacherAuthFile = ref([]); //教师从业资格证
let skillCertificateFile = ref([]); //职业技能证书

async function getInfo() {
  if (!props.archiveBinding.length) return;
  switch (activeName.value) {
    case "1": //教学任务书
      tableData1.value = await proxy.$apis.scheduleRelevant({
        type: "archives-tasks-list",
        data: { archivesId: props.archiveBinding[0]._id },
      });
      //console.log("教学任务书", tableData1.value);
      break;
    case "2": //教师业务档案
      let resp = await proxy.$apis.teachingArchives({
        type: "details",
        data: { _id: props.archiveBinding[0]._id },
      });
      console.log("教师业务档案", resp);
      if (resp.file && resp.file.length) teacherFile.value = resp.file;
      if (resp.diplomaFile && resp.diplomaFile.length)
        diplomaFile.value = resp.diplomaFile;
      if (resp.eduAuthFile && resp.eduAuthFile.length)
        eduAuthFile.value = resp.eduAuthFile;
      if (resp.teacherAuthFile && resp.teacherAuthFile.length)
        teacherAuthFile.value = resp.teacherAuthFile;
      if (resp.skillCertificateFile && resp.skillCertificateFile.length)
        skillCertificateFile.value = resp.skillCertificateFile;
      //console.log("教师业务档案", teacherFile.value);
      break;
    case "3": //听课评议
      break;
    case "4": //考核评价记录
      break;
    default:
      break;
  }
}

watch(
  () => [props.archiveBinding, activeName.value],
  (newValue, oldValue) => {
    if (newValue) getInfo();
  },
  { immediate: true, deep: true }
);
</script>



<style lang="scss" scoped>
.container {
  padding: 15px;
}
</style>

